package com.xframework.model;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuning on 2020/12/30.
 */
public class DynamicDataSourceNameList {

    private List<String> dataSourceNameList = new ArrayList<String>();

    private int dataSourceNameNum = 0;

    private int dataSourceNameIndex = 0;

    public List<String> getDataSourceNameList() {
        return dataSourceNameList;
    }

    public void setDataSourceNameList(List<String> dataSourceNameList) {
        this.dataSourceNameList = dataSourceNameList;
        this.dataSourceNameNum = dataSourceNameList.size();
    }

    public int getDataSourceNameIndex() {
        return dataSourceNameIndex;
    }

    public void setDataSourceNameIndex(int dataSourceNameIndex) {
        this.dataSourceNameIndex = dataSourceNameIndex;
    }

    public String getDataSourceName() {
        int index = dataSourceNameIndex % dataSourceNameNum;
        dataSourceNameIndex++;
        return dataSourceNameList.get(index);
    }

}
